package com.team5101.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.team5101.entity.NextFilm;
import com.team5101.entity.PageDTO;
import com.team5101.service.INextFilmService;
import com.team5101.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/nextfilm")
public class NextFilmController {


    @Autowired
    private INextFilmService nextFilmService;

    @RequestMapping("getall")
    public R getAllNextFilm( Integer nfIshow) {
           return R.ok(nextFilmService.getAllNextFilm(nfIshow));
    }

    @RequestMapping("getone/{nfId}")
    public R selectByFid(@PathVariable  Integer nfId) {
        return R.ok(nextFilmService.selectByFid(nfId));
    }

//    @RequestMapping("getallnfilm")
//    public R  getAllnFilm(PageDTO pageDTO) {
//        if(pageDTO.getCurPage()==null){
//            pageDTO.setCurPage(1);
//        }
//        if(pageDTO.getPageSize()==null){
//            pageDTO.setPageSize(PAGE_SIZE);
//        }
//        PageHelper.startPage(pageDTO.getCurPage(),pageDTO.getPageSize());
//        List<NextFilm> nextFilms = nextFilmService.getNextFilm();
//        PageInfo<NextFilm> pageInfo = new PageInfo<NextFilm>(nextFilms);
//        return  R.ok(pageInfo);
//    }

    @RequestMapping("getallnfilm")
    public R  getAllnFilm(Integer pageNum,Integer pageSize){

        PageHelper.startPage(pageNum, pageSize);
        List<NextFilm> nextFilms = nextFilmService.getNextFilm();
        PageInfo<NextFilm> pageInfo = new PageInfo<NextFilm>(nextFilms);

        return R.ok(pageInfo);
    }



}
